package org.example.business_logic.component;

import lombok.Getter;
import org.example.physics_engine.body.Transform;
import org.example.physics_engine.geometry.shapes.Rectangle;

@Getter
public class StraightOrbit extends Rectangle {

    //轨道横着或者竖着
    public enum OrbitDirection {
        HORIZONTAL,

        VERTICAL
    }

    private OrbitDirection orbitDirection;

    @Deprecated
    public StraightOrbit(){
        this(0,0);
    }

    public StraightOrbit(double halfWidth, double halfHeight, Transform transform){
        super(halfWidth,halfHeight,transform);
        this.orbitDirection=OrbitDirection.VERTICAL;
    }

    public StraightOrbit(double halfWidth,double halfHeight){
        super(halfWidth,halfHeight);
        this.orbitDirection=OrbitDirection.VERTICAL;
    }

    @Override
    public void rotate(double theta, double x,double y){
        transform.rotate(theta,x,y);
        if (Math.abs(this.getTransform().getSint() )> 0.5) {
            this.orbitDirection= OrbitDirection.HORIZONTAL;
        }
        else{
            this.orbitDirection=OrbitDirection.VERTICAL;
        }
    }
}
